﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ZSZ.Core.Entities;

namespace ZSZ.EntityFramework.ModelConfig
{
    class HouseAttachmentConfig:EntityTypeConfiguration<HouseAttachmentEntity>
    {
        public override void Map(EntityTypeBuilder<HouseAttachmentEntity> builder)
        {
            builder.ToTable("T_HouseAttachment");
            builder.HasOne(e => e.House).WithMany(t => t.HouseAttachments).HasForeignKey(u => u.HouseId)
                .OnDelete(DeleteBehavior.ClientSetNull);
            builder.HasOne(e => e.Attachment).WithMany(t => t.HouseAttachments).HasForeignKey(u => u.AttachmentId)
                .OnDelete(DeleteBehavior.ClientSetNull);
        }
    }
}